import {BaseApi, baseWs} from "./Config";
import ServiceApi from "f-fetch-utils/src/ServiceApi";

const LogService = {
    __client__: new ServiceApi("logs", BaseApi),
    log(id, format, readLog) {
        let socket = new WebSocket(baseWs + "/log/" + id + "/" + format);
        socket.onmessage = event => readLog(event.data);
        return socket;
    },
    logs(id, format) {
        return LogService.__client__.Get("/logs/{id}/{format}", {
            urlData: {
                id: id,
                format: format
            }
        });
    }
};
export  default LogService;